﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="StatusControl.ascx.cs" Inherits="POI.eTransmittal.WebApp.Usercontrols.StatusControl" %>

<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dxp" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dxrp" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTimer" TagPrefix="dxt" %>
<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>
<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>
<%--<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPopupControl" TagPrefix="dxpc" %>--%>
<%--<%@ Register Assembly="DevExpress.Web.ASPxEditors.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxEditors" TagPrefix="dxe" %>--%>
<%--<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxTimer" TagPrefix="dxt" %>--%>
<%--<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxRoundPanel" TagPrefix="dxrp" %>--%>
<%--<%@ Register Assembly="DevExpress.Web.v11.2, Version=11.2.7.0, Culture=neutral, PublicKeyToken=b88d1754d700e49a"
    Namespace="DevExpress.Web.ASPxPanel" TagPrefix="dxp" %>--%>

<script type="text/javascript"><!--
var isMoveToBottom = false;
var errLabel = "Error:";
var statusLabel = "Status:";
var errString="";
var extention;
var haltAnchor = <%=haltAnchor%> ; //used for flag in MocHeaderControl
String.IsNullOrEmpty = function(value) {
  var isNullOrEmpty = true;
  if (value) {
   if (typeof (value) == 'string') {
    if (value.length > 0)
     isNullOrEmpty = false;
   }
  }
  return isNullOrEmpty;
 }
 function setOkExtention(ext)
 {
 extention=ext;
 }
 function onOkExtention()
 {
 if(extention!=null ||extention!=undefined){
 extention();
 }
 }
var statusCounter;
function StatusTick(){
    statusCounter -= 1;
    StatusUpdate();
}

function GetNavigateUrl(){
    return lblUrl.GetValue();    
}

    function GetNavigateUrl() {
        return lblUrl.GetValue();
    }

function StatusUpdate(){
    if(statusCounter > 0){
        Timer1.SetEnabled(true);
        //document.getElementById("demoCountdown").innerHTML = statusCounter.toString();
        
    }
    else{
        Timer1.SetEnabled(false);
        pnlStatus.Hide();
    }
}

function StatusInit(){
    statusCounter = 0;
    pnlStatus.hide();
}

function ShowStatusMessage(msg){
    haltAnchor = true;    
    lblStatus.SetValue(msg);
//    statusCounter = 2;
    pnlStatus.Show();
//    StatusUpdate();
    btnStsOk.SetFocus();
}

function ShowErrSource(){
    var isVisible = pnlSource.GetClientVisible();
    linkSource.SetText(isVisible ? 'View Source' :'Hide Source');
    pnlSource.SetClientVisible(!isVisible);
  
    if(!isVisible)
        lblSource.SetText(errString);
}
function ShowErrorMessage(msg){
    var idxStart = errLabel.length;
    var idxEnd = msg.indexOf(";");
    var message = '';
    
    HideLoading();
    if(idxEnd > -1){
        message = msg.substring(idxStart,idxEnd);
    }
    else{
        message = msg.substring(idxStart);
        pnlSource.SetClientVisible(false);
        linkSource.SetClientVisible(false);
    }
    
    var source = msg.substring(idxEnd+1);
    lblMessage.SetText(message);
    errString=source;
    
    
    //pnlErrorMsg.SetClientVisible(true);
    haltAnchor = true;
    pcErrorMessage.Show();
    
    btnOk.SetFocus();
    
}
    
    
function ShowStatus(msg){
    haltAnchor = true;    
    //pnlErrorMsg.SetClientVisible(false);
    if(msg.indexOf(errLabel) > -1){
        ShowErrorMessage(msg);    
    }
    else{
        if(msg.indexOf(statusLabel) > -1){
            var idxStart = statusLabel.length;
            var stsMsg = msg.substring(idxStart);
            ShowStatusMessage(stsMsg);   
        }        
    }
}
function ShowStatus(msg, url){
    //pnlErrorMsg.SetClientVisible(false);
    if(msg.indexOf(errLabel) > -1){
        ShowErrorMessage(msg);   
       
    }
    else{
        if(msg.indexOf(statusLabel) > -1){
            var idxStart = statusLabel.length;
            var stsMsg = msg.substring(idxStart);
            lblUrl.SetText(url);
            ShowStatusMessage(stsMsg);   
        }        
    }
}

function ShowLoading(msg)
{
    if ( msg != null && msg != '' )
    {        
        lblLoading.SetText(msg);
    }
    else
    {
        lblLoading.SetText('Loading...');
    }
    popcLoading.Show();
}

function HideLoading()
{
    popcLoading.Hide();
}

function ShowErrorCallbackMessage(s, e)
{
	HideLoading();
	ShowStatus("Error:" + e.message);
	e.handled = true;	
}
//--></script>

<dxpc:ASPxPopupControl ID="pnlStatus" runat="server" EnableTheming="True" HeaderText="Status"
    Width="300px" ClientInstanceName="pnlStatus" Modal="True" PopupAction="None"
    PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="TopSides" CloseAction="None"
    BackColor="Transparent" ShowHeader="False" ShowShadow="False" 
    RenderIFrameForPopupElements="True">
    <ContentCollection>
        <dxpc:PopupControlContentControl ID="PopupControlContentControl1" runat="server">
            <dxrp:ASPxRoundPanel ID="ASPxRoundPanel2" runat="server" HeaderText="Information"
                Width="100%">
                <PanelCollection>
                    <dxp:PanelContent ID="PanelContent1" runat="server">
                        <table width="100%">
                            <tr>
                                <td style="width: 100%">
                                    <dxe:ASPxLabel ID="lblStatus" runat="server" ClientInstanceName="lblStatus" Text="Saved Successfully">
                                    </dxe:ASPxLabel>
                                    <br />
                                    <dxe:ASPxLabel ID="lblUrl" runat="server" ClientInstanceName="lblUrl" ClientVisible="False">
                                    </dxe:ASPxLabel>
                                </td>
                            </tr>
                            <tr>
                                <td align="center" style="width: 100%" valign="bottom">
                                    <br />
                                    <dxe:ASPxButton ID="btnStsOk" runat="server" AutoPostBack="False" ClientInstanceName="btnStsOk"
                                        Text="OK" Width="80px" CausesValidation="False" AllowFocus="False">
                                        <ClientSideEvents Click="function(s, e) {
	pnlStatus.Hide();
       if (isMoveToBottom == null)
       {
       }
       else if (isMoveToBottom != null)
       {
            if ( haltAnchor && isMoveToBottom)
            {
                window.location.hash='MocHeaderStartContent';
                isFirstTime = false;
            }
       }
       onOkExtention();	
	if(lblUrl.GetText() != &quot;&quot; &amp;&amp; lblUrl.GetText()!= null){
		window.location = lblUrl.GetText();		
	}
}" />
                                    </dxe:ASPxButton>
                                </td>
                            </tr>
                        </table>
                    </dxp:PanelContent>
                </PanelCollection>
                <Border BorderStyle="None" />
            </dxrp:ASPxRoundPanel>
        </dxpc:PopupControlContentControl>
    </ContentCollection>
    <CloseButtonImage Height="16px" Width="15px" />
    <SizeGripImage Height="16px" Width="16px" />
    <ClientSideEvents CloseUp="function(s, e) {	
    if(GetNavigateUrl().toString() != 'ASPxLabel' &amp;&amp; GetNavigateUrl().toString() != '')
     {
	    window.location = GetNavigateUrl().toString();
	    }
}" />
    <ContentStyle>
        <Paddings Padding="0px" />
        <Border BorderStyle="None" />
    </ContentStyle>
    <Border BorderStyle="None" />
</dxpc:ASPxPopupControl>
<dxpc:ASPxPopupControl ID="pcErrorMessage" runat="server" EnableTheming="True" HeaderText="Error"
    Width="700px" ClientInstanceName="pcErrorMessage" Modal="True" PopupAction="None"
    PopupHorizontalAlign="WindowCenter" PopupVerticalAlign="WindowCenter" CloseAction="CloseButton"
    BackColor="Transparent" ShowShadow="False" ShowHeader="False">
    <ContentCollection>
        <dxpc:PopupControlContentControl ID="PopupControlContentControl2" runat="server">
            <!--<span id="demoCountdown" style="font-weight: bold; color: #59A1E9;">&nbsp;</span> seconds.&nbsp;-->
            <dxrp:ASPxRoundPanel ID="ASPxRoundPanel1" runat="server" HeaderText="Error" Width="100%">
                <PanelCollection>
                    <dxp:PanelContent ID="PanelContent2" runat="server">
                        <table cellspacing="0" cellpadding="0" width="100%" style="border-right: lightgrey thin solid;
                            border-top: lightgrey thin solid; border-left: lightgrey thin solid; border-bottom: lightgrey thin solid">
                            <tbody>
                                <tr>
                                    <td valign="top">
                                        <dxe:ASPxLabel runat="server" Text="ASPxLabel" ClientInstanceName="lblMessage" ID="lblMessage">
                                        </dxe:ASPxLabel>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="background-color: gainsboro" align="right">
                                        <dxe:ASPxHyperLink runat="server" NavigateUrl="javascript:ShowErrSource();" Text="View Source"
                                            ClientInstanceName="linkSource" ID="linkSource">
                                        </dxe:ASPxHyperLink>
                                    </td>
                                </tr>
                                <tr>
                                    <td style="border-bottom: lightgrey thin solid">
                                        <dxp:ASPxPanel runat="server" ClientInstanceName="pnlSource" Width="100%" ID="pnlSource"
                                            ClientVisible="False">
                                            <PanelCollection>
                                                <dxp:PanelContent ID="PanelContent3" runat="server">
                                                    <dxe:ASPxLabel runat="server" ClientInstanceName="lblSource" ID="lblSource">
                                                    </dxe:ASPxLabel>
                                                </dxp:PanelContent>
                                            </PanelCollection>
                                        </dxp:ASPxPanel>
                                    </td>
                                </tr>
                                <tr>
                                    <td align="center" style="height: 63px">
                                        <br />
                                        <dxe:ASPxButton runat="server" AutoPostBack="False" ClientInstanceName="btnOk" Text="OK"
                                            Width="80px" ID="btnOk" CausesValidation="False" AllowFocus="False">
                                            <ClientSideEvents Click="function(s, e) {
	pcErrorMessage.Hide();
}"></ClientSideEvents>
                                        </dxe:ASPxButton>
                                    </td>
                                </tr>
                            </tbody>
                        </table>
                    </dxp:PanelContent>
                </PanelCollection>
                <Border BorderStyle="None" />
            </dxrp:ASPxRoundPanel>
        </dxpc:PopupControlContentControl>
    </ContentCollection>
    <ClientSideEvents CloseUp="function(s, e) {	
    if(GetNavigateUrl().toString() != 'ASPxLabel' && GetNavigateUrl().toString() != '')
     {
	    window.location = GetNavigateUrl().toString();
	    }
}" />
    <HeaderStyle BackColor="Transparent" />
    <CloseButtonImage Height="16px" Width="15px" />
    <ContentStyle>
        <Paddings Padding="0px" />
    </ContentStyle>
    <Border BorderStyle="None" />
</dxpc:ASPxPopupControl>
<table width="700">
    <tr>
        <td style="width: 100%">
            <dxrp:ASPxRoundPanel ID="pnlWarningMsg" runat="server" ClientInstanceName="pnlWarningMsg"
                ClientVisible="False" EnableTheming="True" HeaderText="Warning" Width="100%">
                <PanelCollection>
                    <dxp:PanelContent ID="PanelContent4" runat="server">
                        <dxp:ASPxPanel runat="server" ClientInstanceName="pnlContentMsg" Width="100%" BackColor="Transparent"
                            ID="pnlContentMsg">
                            <PanelCollection>
                                <dxp:PanelContent ID="PanelContent5" runat="server">
                                    <table cellspacing="0" cellpadding="0" width="100%">
                                        <tbody>
                                            <tr>
                                                <td>
                                                    <dxe:ASPxLabel runat="server" Text="ASPxLabel" ClientInstanceName="lblWarning" ID="lblWarning">
                                                    </dxe:ASPxLabel>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td align="right">
                                                    <dxe:ASPxHyperLink runat="server" NavigateUrl="javascript:ShowErrSource();" Text="View Source"
                                                        ClientInstanceName="linkWarnSource" ID="linkWarnSource">
                                                    </dxe:ASPxHyperLink>
                                                </td>
                                            </tr>
                                            <tr>
                                                <td>
                                                    <dxp:ASPxPanel runat="server" ClientInstanceName="pnlWarnSource" Width="100%" ID="pnlWarnSource">
                                                        <PanelCollection>
                                                            <dxp:PanelContent ID="PanelContent6" runat="server">
                                                                <dxe:ASPxLabel runat="server" Text="" ClientInstanceName="lblSourceWarning" ID="lblSourceWarning">
                                                                </dxe:ASPxLabel>
                                                            </dxp:PanelContent>
                                                        </PanelCollection>
                                                    </dxp:ASPxPanel>
                                                </td>
                                            </tr>
                                        </tbody>
                                    </table>
                                </dxp:PanelContent>
                            </PanelCollection>
                        </dxp:ASPxPanel>
                    </dxp:PanelContent>
                </PanelCollection>
                <HeaderTemplate>
                    <table cellspacing="0" cellpadding="0">
                        <tbody>
                            <tr>
                                <td nowrap>
                                    Warning
                                </td>
                                <td style="padding-left: 5px; width: 1%" nowrap>
                                    <dxe:ASPxButton ID="btnExpandCollapse" Width="20px" runat="server" Text="-" CausesValidation="False"
                                        AutoPostBack="False" AllowFocus="False">
                                        <Paddings Padding="1px" />
                                        <FocusRectPaddings Padding="0px" />
                                        <ClientSideEvents Click="function(s, e) {
                                                var isVisible = pnlContentMsg.GetClientVisible();
                                                s.SetText(isVisible ? &quot;+&quot; : &quot;-&quot;);
                                                pnlContentMsg.SetClientVisible(!isVisible);
                                                }" />
                                    </dxe:ASPxButton>
                                </td>
                            </tr>
                        </tbody>
                    </table>
                </HeaderTemplate>
                <Border BorderStyle="None"></Border>
            </dxrp:ASPxRoundPanel>
        </td>
    </tr>
</table>
<dxt:ASPxTimer ID="ASPxTimer1" runat="server" Interval="1000" ClientInstanceName="Timer1"
    Enabled="False">
    <ClientSideEvents Tick="function(s, e) {
	StatusTick();
}" />
</dxt:ASPxTimer>
<dxpc:ASPxPopupControl ID="popcLoading" runat="server" EnableTheming="True" HeaderText="Status"
    ClientInstanceName="popcLoading" Modal="True" PopupAction="None" PopupHorizontalAlign="WindowCenter"
    PopupVerticalAlign="WindowCenter" CloseAction="None" ShowHeader="False" 
    Width="115px" BackColor="Transparent">
    <ContentCollection>
        <dxpc:PopupControlContentControl ID="PopupControlContentControl3" runat="server">
            <table style="margin-left: auto; margin-right: auto">
                <tr>
                    <td style="text-align: center">
                        <dxe:ASPxImage ID="imgLoading" runat="server" ImageAlign="Middle" ImageUrl="~/Images/loading.gif">
                        </dxe:ASPxImage>
                    </td>
                </tr>
                <tr>
                    <td style="text-align: center">
                        <dxe:ASPxLabel ID="lblLoading" runat="server" Text="Loading..." ClientInstanceName="lblLoading">
                        </dxe:ASPxLabel>
                    </td>
                </tr>
            </table>
        </dxpc:PopupControlContentControl>
    </ContentCollection>
</dxpc:ASPxPopupControl>
